package cn.ito.zjgsu.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ito.zjgsu.constant.StatusCode;
import cn.ito.zjgsu.domain.Project;
import cn.ito.zjgsu.service.ProjectService;

/**
 * 
 * @author sjjok
 *
 */

@Controller
public class ProjectController {

	@Autowired
	ProjectService proService;
	
	@RequestMapping(value="/tender/projects/{projectId}", method = RequestMethod.GET)
	public @ResponseBody Map<String, Object> showProById(@PathVariable int projectId) {
		Map<String, Object> result = new HashMap<>();
		Project pro = proService.getProById(projectId);
		result.put("project", pro);
		return result;
	}
	
	@RequestMapping(value="tender/project/{projectId}", method = RequestMethod.DELETE)
	public @ResponseBody Map<String, Object> CancelProById(@PathVariable int projectId) {
		Map<String, Object> result = new HashMap<>();
		proService.cancelProById(projectId);
		result.put("STATUS", StatusCode.SUCCESS_STATUS);
		return result;
	}
}
